<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/tern/tern-tags.tld" prefix="tern" %>
<tern:page pageForm="com.web.pages.ClassPage">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
     <title>教学班信息</title>
     <meta http-equiv="pragma" content="no-cache" />
     <meta http-equiv="cache-control" content="no-cache" />
     <meta http-equiv="expires" content="0" />  
     <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/skins/default/main.css">
     <link type="text/css" href="<%=request.getContextPath()%>/js/themes/ui-lightness/jquery.ui.all.css" rel="stylesheet" />
     <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script>  
     <script type="text/javascript" src="<%=request.getContextPath()%>/js/ui/jquery-ui.min.js"></script>         
     <script type="text/javascript" src="<%=request.getContextPath()%>/js/util.js"></script>
     <script language="javascript">
        $(function(){
        	$('#btnAdd').click(function(){
        		openDialog('classEdit.jsp?time=' +(new Date()).getTime(),460);
            });

        	$('#enTable A').click(function(){
                var name = $(this).attr('href');
                if(name == '#del'){
                	deleteItems($(this));
                }else if(name == '#modify'){
                	var id = $(this).parent().parent().find('input[name=checkbox]').val();
                	openDialog('classEdit.jsp?id='+id+'&time=' +(new Date()).getTime(),460 );
                }
            });

            $('#enTable').parent().find('div.pinfo')
               .prepend("<span><input name='btnDel' type='button' id='btnDel' class='inputButton' value=' 删除 '/></span>");

            $('#btnDel').click(function(){
            	var $items = $('input:checked[name=checkbox]');
            	if(!$items.length){
            		alert('您没有选中任何数据!');
            		return;
            	}
            	deleteItems($items);
            });
        });

        function deleteItems($items){
        	askYesOrNo({
        		message:'您确实要删除选中的教学信息吗？',
        		onok:function(){
        		    var sels = '';
        		    $items.each(function(){
            		    if(sels.length>0) sels+=',';
        		    	sels+=$(this).parent().parent().find('input[name=checkbox]').val();
            		});
        		    $('#myForm').onevent('onDel',sels);
        	    }
            });
        }
     </script>
     <style type="text/css">
        body {margin:0px 8px 8px;}
     </style>
</head>
<body>
<br>
  <tern:form method="post" id="myForm">
        <div class="toolbar">
           <input type="button" name="btnAdd" value="新增" id="btnAdd" class="inputButton" style="width:79px;" />
        </div>
        <tern:table id="enTable" dataSource="${page.classes}">
            <tern:theader>
                <tern:tcell width="75" height="24" align="center">选择</tern:tcell>
                <tern:tcell align="center">ID</tern:tcell>
                <tern:tcell align="center">课程</tern:tcell>
                <tern:tcell align="center">老师</tern:tcell>
                <tern:tcell align="center">开课时间 </tern:tcell>
                <tern:tcell align="center">操作</tern:tcell>
	        </tern:theader>
	        <tern:trow>	
                <tern:tcell height="22" align="center">
                   <input value='${item.classID}' name="checkbox" type="checkbox" />                    
                </tern:tcell>
                <tern:tcell>&nbsp;${item.classID}</tern:tcell>
                <tern:tcell>&nbsp;${item.courseID}</tern:tcell>
                <tern:tcell>&nbsp;${item.teacherID}</tern:tcell> 
                <tern:tcell>&nbsp;${item.startTime}</tern:tcell>                 
                <tern:tcell>                    
                    <a href="#modify" rindex="${rindex}"><img src="<%=request.getContextPath()%>/skins/common/icon_edit.gif" alt="修改" />编辑</a>                    
			        <a href="#del"><img src="<%=request.getContextPath()%>/skins/common/icon_del.gif" alt="删除" />删除</a>
                </tern:tcell>
	       </tern:trow>	       
        </tern:table>
        <input name="b_refreah" type="button" value="刷新" style="display:none" onClick="on_event('onRefresh','')"/>
  </tern:form>
</body>
</html>
</tern:page>
